package org.meteorshower.employee_depart.remote.system_depart_role;

import org.meteorshower.system_depart.entity.Role;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Role服务降级处理类
 * */
@Component
public class RoleClientFallBackFactory implements FallbackFactory<RoleServiceClient> {
    @Override
    public RoleServiceClient create(Throwable cause) {
        return new RoleServiceClient() {
            @Override
            public List<Role> getRoleAll() throws Exception {
                return List.of(new Role(4,"ROLE_EMPLOYEE","员工"));
            }

            @Override
            public Role getRoleById(Integer id) throws Exception {
                return new Role(4,"ROLE_EMPLOYEE","员工");
            }

            @Override
            public Role getRoleByName(String name) throws Exception {
                return new Role(4,"ROLE_EMPLOYEE","员工");
            }
        };
    }
}
